//
//  CashierNewDataModel.m
//  TryShopping
//
//  Created by LiYinDi on 16/6/7.
//  Copyright © 2016年 RuiBen. All rights reserved.
//

#import "CashierNewDataModel.h"

@implementation CashierNewDataModel
+(instancetype)dataModelWithDict:(NSDictionary *)dict
{
    CashierNewDataModel *dataModel=[[self alloc] init];
    NSArray *imgArray=dict[@"imageList"];
    if (imgArray.count>0) {
        dataModel.imageUrlFull=imgArray[0][@"imageUrlFull"];
    }
    else
    {
         dataModel.imageUrlFull=@"";
    }
   
    dataModel.itemCode=[NSString stringWithFormat:@"%@",dict[@"itemCode"]];
    
    dataModel.itemId=[NSString stringWithFormat:@"%@",dict[@"itemId"]];
    dataModel.itemName=[NSString stringWithFormat:@"%@",dict[@"itemName"]];
   
    if ([[Global getType] isEqualToString:@"NeedOrder"]) {//要货成本价
        NSString *str1=[NSString stringWithFormat:@"%d",TARGET_VERSION];
        if ([str1 isEqualToString:@"4"]) {
            dataModel.maxPrice=[Global getJudgeTheErrorStr:dict[@"maxCostPrice"]];
            dataModel.minPrice=[Global getJudgeTheErrorStr:dict[@"minCostPrice"]];
            dataModel.salePrice=[Global getJudgeTheErrorStr:dict[@"costPrice"]];
            
        }else{
            dataModel.maxPrice=[Global getJudgeTheErrorStr:dict[@"maxPrice"]];
            dataModel.minPrice=[Global getJudgeTheErrorStr:dict[@"minPrice"]];
            dataModel.salePrice=[Global getJudgeTheErrorStr:dict[@"dealPrice"]];
            
        }
        
    }else{
        
        dataModel.maxPrice=[Global getJudgeTheErrorStr:dict[@"maxPrice"]];
        dataModel.minPrice=[Global getJudgeTheErrorStr:dict[@"minPrice"]];
        dataModel.salePrice=[Global getJudgeTheErrorStr:dict[@"dealPrice"]];
        
    }


    dataModel.invQty=[NSString stringWithFormat:@"%@",dict[@"invQty"]];
    dataModel.specType=[NSString stringWithFormat:@"%@",dict[@"specType"]];
    dataModel.specCount=[NSString stringWithFormat:@"%@",dict[@"specCount"]];
    
    
    if (dict[@"currentSpec"]&&dict[@"currentSpec"]!=[NSNull null] ) {
        
     dataModel.specInv=[NSString stringWithFormat:@"%@",dict[@"currentSpec"][@"specInv"]];
     dataModel.specPrice=[NSString stringWithFormat:@"%@",dict[@"currentSpec"][@"specPrice"]];
     dataModel.specId=[NSString stringWithFormat:@"%@",dict[@"currentSpec"][@"specId"]];
     dataModel.colourId=[NSString stringWithFormat:@"%@",dict[@"currentSpec"][@"colourId"]];
     dataModel.sizeId=[NSString stringWithFormat:@"%@",dict[@"currentSpec"][@"sizeId"]];
     dataModel.specName=[NSString stringWithFormat:@"%@",dict[@"currentSpec"][@"specName"]];
    }
   else
   {
       dataModel.specInv=@"";
       dataModel.specPrice=@"";
       dataModel.specId=@"";
       dataModel.colourId=@"";
       dataModel.sizeId=@"";
       dataModel.specName=@"";
   }
      
    return dataModel;

}

@end
